package util;

import org.newdawn.slick.Color;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.geom.Rectangle;

/**
 * Specialized rectangle class.
 * @author VincentLy
 */
public class Rect extends Rectangle{

	private Color color;
	
	public Rect(float x, float y, float w, float h,int c) {
		super(x,y,w,h);
		switch(c){
		case 0:
			color = Color.red;
			break;
		case 1:
			color = Color.orange;
			break;
		case 2:
			color = Color.yellow;
			break;
		case 3:
			color = Color.green;
			break;
		case 4:
			color = Color.blue;
			break;
		case 5:
			color = Color.white;
			break;
		case 6:
			color = Color.black;
			break;
		}
	}

	/**
	 * @return x
	 * @author VincentLy
	 */
	public float x(){return getCenterX();}		

	/**
	 * @return y
	 * @author VincentLy
	 */
	public float y(){return getCenterY();}

	/**
	 * @return x left
	 * @author VincentLy
	 */
	public float left(){return getMinX();}

	/**
	 * @return x right
	 * @author VincentLy
	 */
	public float right(){return getMaxX();}

	/**
	 * @return y top
	 * @author VincentLy
	 */
	public float top(){return getMinY();}

	/**
	 * @return y bottom
	 * @author VincentLy
	 */
	public float bottom(){return getMaxY();}

	/**
	 * @return width
	 * @author VincentLy
	 */
	public float width(){return getWidth();}

	/**
	 * @return height
	 * @author VincentLy
	 */
	public float height(){return getHeight();}

	/**
	 * @return color
	 * @author VincentLy
	 */
	public Color color(){return color;}
	
	/**
	 * Moves the rectangle to a point (x,y)
	 * @param x
	 * @param y
	 * @author VincentLy
	 */
	public void move(float x,float y){setLocation(x-width()/2,y-height()/2);}
	
	/**
	 * Draws the rectangle.
	 * @param g - Graphics
	 * @author VincentLy
	 */
	public void draw(Graphics g){
		g.setColor(color);
		g.draw(this);
	}
}